<?php

/** @see Zend_View_Helper_Abstract */
require_once 'Zend/View/Helper/Abstract.php';

/**
 * Helper for retrieving the BaseUrl
 */
class My_View_Helper_PlaySong extends Zend_View_Helper_Abstract
{

    /**
     * Generates flash widget which plays one given song based on grooveshark song ID
     * 
     * @param integer $songID Grooveshark song ID
     * @param bool $autostart
     * @param int $width
     * @param int $height
     * @param string $style
     * @return string 
     */

    public function PlaySong($songID, $autostart = false, $width = 220, $height = 40, $style = 'wood')
    {
        $autostart = (int) $autostart;

        $xhtml = '';

        $xhtml .= '<object width="' . $width . '" height="' . $height . '">';
        $xhtml .= '<param name="movie" value="http://listen.grooveshark.com/songWidget.swf"></param>';
        $xhtml .= '<param name="wmode" value="window"></param>';
        $xhtml .= '<param name="allowScriptAccess" value="always"></param>';
        $xhtml .= '<param name="flashvars" value="hostname=cowbell.grooveshark.com&amp;songID=' . $songID . '&amp;style=wood&amp;p=' . $autostart . '"></param>';
        $xhtml .= '<embed src="http://listen.grooveshark.com/songWidget.swf" type="application/x-shockwave-flash" width="' . $width . '" height="' . $height . '"';
        $xhtml .= 'flashvars="hostname=cowbell.grooveshark.com&amp;songID=' . $songID . '&amp;style=' . $style . '&amp;p=' . $autostart . '" allowScriptAccess="always" wmode="window"></embed>';
        $xhtml .= '</object>';

        return $xhtml;
    }

}
